<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <script src="http://localhost:8080/socket.io/socket.io.js" charset="utf-8"></script>
  <script src="jquery.js" charset="utf-8"></script>
  <script type="text/javascript">
    $(function(){
      let sock = io.connect('ws://localhost:8080/');
      $('#send').click(function(){
        console.log('点击了');
        let txt = document.getElementById('str');
        console.log(txt);
        if($('#str').val().trim()!=''){
          sock.emit('msg',txt.value);
        }
      });
      sock.on('msg',function(str){
        $('.div1').append(`<input type="text" value="${str}"/><br>`)
      });
    });
  </script>
  <title>Document</title>
  <style media="screen">
    .div1{
      width: 600;
      height: 400;
      border: 1px;
      overflow: auto;
    }
  </style>
</head>
<body>
  <div class='div1'>
  </div>
  <textarea name="name" rows="8" cols="60" id="str"></textarea>
  <input type="button" id="send" value="发送">
</body>
</html>
